package com.cloud.code.真题;

import java.util.*;

public class Demo24 {

    public static void main(String[] args) {
        String str = "i LOVE Cc I love CC Hello Hel Hellow";
        String[] s = str.split(" ");

        Map<String,String> map = new HashMap<>();

        for (int i = 0; i < s.length; i++) {
            String tem = s[i];
            String low = tem.toLowerCase(Locale.ROOT);
            String s1 = map.get(low);
            if(s1 == null){
                map.put(low,tem);
            }
        }

        List<Map.Entry<String,String>> list = new ArrayList<>(map.entrySet());
        list.sort(new Comparator<Map.Entry<String, String>>() {
            @Override
            public int compare(Map.Entry<String, String> o1, Map.Entry<String, String> o2) {
                return o1.getKey().compareTo(o2.getKey());
            }
        });

        list.forEach(tem -> {
            System.out.println(tem.getValue());
        });
    }
}
